package com.xiaoshuidi.cloud.module.contract.controller.app.invoice;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.common.pojo.PageParam;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;

import com.xiaoshuidi.cloud.framework.security.core.util.SecurityFrameworkUtils;

import com.xiaoshuidi.cloud.module.contract.controller.app.invoice.vo.InvoiceRespVO;
import com.xiaoshuidi.cloud.module.contract.service.contract.ContractInvoiceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import javax.annotation.security.PermitAll;
import java.util.Objects;

@Tag(name = "租客 APP - 发票")
@RestController
@RequestMapping("/contract/invoice")
public class AppInvoiceController {
    @Resource
    private ContractInvoiceService contractInvoiceService;

    @GetMapping("/page")
    @PermitAll
    @Operation(summary = "可开票列表")
    public CommonResult<PageResult<InvoiceRespVO>> page(PageParam reqVO) {
//        Long tenantId = Objects.requireNonNull(SecurityFrameworkUtils.getLoginUser()).getTenantId();
        Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
        return CommonResult.success(contractInvoiceService.getCustomerInvoiceablePage(loginUserId, reqVO));
    }
}
